package com.egg.ylt.presenter;

import com.egg.ylt.Utils.API;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.Utils.StringUtil;
import com.egg.ylt.pojo.SwitchBabyEntity;
import com.egg.ylt.view.ISwitchBabyView;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;

/**
 * Created by lijiateng on 2019/1/21.
 */

public class SwitchBabyPresenter extends BasePresenter<ISwitchBabyView> {


    public void requestBabyList() {
        mView.showLoading("正在加载中...");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("token", Constants.TOKEN);
        hashMap.put("companyId", Constants.COMPANYID);
        RequestManager.getInstance().requestPostByAsyn(API.GET_BABY_LIST, hashMap, new ReqCallBack<SwitchBabyEntity>() {
            @Override
            public void onReqSuccess(SwitchBabyEntity result) {
                mView.hideLoading();
                mView.updateBabyList(result.getList());
            }

            @Override
            public void onFailure(String result) {
                mView.hideLoading();
                mView.showError(result);
            }

            @Override
            public void onReqFailed(ErrorBean error) {
                mView.hideLoading();
                mView.showBusinessError(error);
            }
        });
    }

}
